local lieren = fk.CreateSkill {

  name = "joyex__lieren",

  tags = {  },

}



lieren:addEffect(fk.TargetSpecified, {
  name = "joyex__lieren",
  anim_type = "control",
  events = {fk.TargetSpecified},
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(lieren.name) then
        if data.card and data.card.trueName == "slash" and not player:isKongcheng() then
          local to = player.room:getPlayerById(data.to)
          return not to.dead and not to:isKongcheng()
        end
    end
  end,
  on_trigger = function(self, event, target, player, data)
      self:doCost(event, target, player, data.to)
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
      if room:askForSkillInvoke(player, lieren.name, nil, "#joyex__lieren-invoke::"..data) then
        room:doIndicate(player.id, {data})
        return true
      end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
      local to = room:getPlayerById(data)
      local pindian = player:pindian({to}, lieren.name)
      if room:getCardArea(pindian.results[to.id].toCard) == Card.DiscardPile then
        room:delay(1000)
        room:obtainCard(player, pindian.results[to.id].toCard, true, fk.ReasonJustMove)
      end
      if pindian.results[to.id].winner == player and not player.dead and not to.dead and not to:isNude() then
        local id = room:askForCardChosen(player, to, "he", lieren.name)
        room:obtainCard(player, id, false, fk.ReasonPrey)
      end
  end,
})

return lieren